// pages/my/myteam/myteam.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    jifen: [{
      integral: "10",
      coupon: "12",
      balance: "100",
    }],
    height: 0,
    widHeight:0,
    currentTab: 0,
    zhangsan: [{
        touxiang: "../../images/timg.jpg",
        zhangsan: "张三",
        time: "注册时间：2018-12-04 12:00",
        ren: "推荐人：我想静静",
        zhitui: "../../images/zhitui.png",
      },
    ],
    lisi: [{
      touxiang: "../../images/timg.jpg",
      zhangsan: "李四",
      time: "注册时间：2018-12-04 12:00",
      ren: "推荐人：我想静静",
      zhitui: "../../images/zhitui.png",
    },
    ]
  },

 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var query = wx.createSelectorQuery();
    var that = this;
    /**
     * 获取系统信息
     */
    var zhang = this.data.zhangsan.length;
    query.select('.main').boundingClientRect(function (rect) {
      
      that.setData({
        // 获取要循环标签的高度
        height: rect.height ,
        widHeight: rect.height * zhang + "px"
      })
    }).exec();
  },
  //滑动切换
  swiperTab: function(e) {
    var that = this;
    // 获取单个轮播循环的高度
    var heights=this.data.height;
    // 获取一级成员的数组个数
    var zhang = this.data.zhangsan.length
    // 获取二级成员的数组个数
    var lisi = this.data.lisi.length
    console.log(heights)
    that.setData({
      currentTab: e.detail.current
    });
    if (this.data.currentTab==0){
      that.setData({
        widHeight: heights * zhang+"px"
      });
      console.log(2222)
      console.log(this.data.zhangsan.length)
    }else{
      that.setData({
        widHeight: heights * lisi + "px"
      });
      console.log(2222)
      console.log(this.data.lisi.length)
    }
    // console.log(e.detail.current);
  },
  //点击切换
  clickTab: function(e) {

    var that = this;

    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})
